package io.renren.modules.app.controller;

import java.util.Arrays;
import java.util.Map;

import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;
import io.renren.modules.app.entity.BsDrugEntity;
import io.renren.modules.app.service.BsDrugService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;





/**
 * 药品字典表
 *
 */
@RestController
@RequestMapping("tb_bs_drug/bsdrug")
public class BsDrugController {
    @Autowired
    private BsDrugService bsDrugService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("tb_bs_drug:bsdrug:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = bsDrugService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("tb_bs_drug:bsdrug:info")
    public R info(@PathVariable("id") Long id){
		BsDrugEntity bsDrug = bsDrugService.getById(id);

        return R.ok().put("bsDrug", bsDrug);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("tb_bs_drug:bsdrug:save")
    public R save(@RequestBody BsDrugEntity bsDrug){
		bsDrugService.save(bsDrug);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("tb_bs_drug:bsdrug:update")
    public R update(@RequestBody BsDrugEntity bsDrug){
		bsDrugService.updateById(bsDrug);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("tb_bs_drug:bsdrug:delete")
    public R delete(@RequestBody Long[] ids){
		bsDrugService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
